{% extends 'admin/master.html' %}
{% import 'admin/lib.html' as lib with context %}

{% macro extra(is_edit=0) %}
    {% if admin_view.can_create %}
        <input name="_add_another" type="submit" class="btn btn-default"
               value="{{ _gettext('Save and Add Another') }}"/>
    {% endif %}
    {% if admin_view.can_edit %}
        <input name="_continue_editing" type="submit" class="btn btn-default"
               value="{{ _gettext('Save and Continue Editing') }}"/>
    {% endif %}
    {% if is_edit == 1 and admin_view.can_delete_in_detail %}
        <a href="{{ get_url('.delete_view') + request.args.get('id') }}"
           onclick="return faHelpers.safeConfirm('{{ _gettext('Are you sure you want to delete this record?') }}');"
           class="btn btn-danger" role="button">删除</a>
    {% endif %}
{% endmacro %}

{% block head %}
  {{ super() }}
  {{ lib.form_css() }}
{% endblock %}

{% block body %}
  {% block navlinks %}
  <ul class="nav nav-tabs">
    <li>
        <a href="{{ return_url }}">{{ _gettext('List') }}</a>
    </li>
    {%- if admin_view.can_create -%}
    <li>
        <a href="{{ get_url('.create_view', url=return_url) }}">{{ _gettext('Create') }}</a>
    </li>
    {%- endif -%}
    <li class="active">
        <a href="javascript:void(0)">{{ _gettext('Edit') }}</a>
    </li>
    {%- if admin_view.can_view_details -%}
    <li>
        <a href="{{ get_url('.details_view', id=request.args.get('id'), url=return_url) }}">{{ _gettext('Details') }}</a>
    </li>
    {%- endif -%}
  </ul>
  {% endblock %}

  {% block edit_form %}
    {{ lib.render_form(form, return_url, extra(1), form_opts, form_layout=admin_view.form_layout) }}
  {% endblock %}
{% endblock %}

{% block tail %}
  {{ super() }}
  {{ lib.form_js() }}
{% endblock %}
